package com.wing.common.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 合同变更记录
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("com_contract_change_record")
public class ContractChangeRecord extends BaseEntity<ContractChangeRecord> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum Status implements IEnum<Integer> {

        /**
        * 待审核
        */
        stayAudit(0,"待审核"),
        /**
        * 审核成功
        */
        success(1,"审核成功"),
        /**
        * 审核失败
        */
        fail(2,"审核失败"),
        /**
        * 已签约
        */
        hasSign(3,"已签约"),
        /**
         * 已废弃
         */
        hasDiscard(4,"已废弃");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 合同ID
     */
    private Long contractId;

    /**
     * 合同分类ID
     */
    private Long contractCategoryId;

    /**
     * 名称
     */
    private String name;

    /**
     * 编号
     */
    private String code;

    /**
     * 客户签约人ID
     */
    private Long contactsId;

    /**
     * 我方签约人ID
     */
    private Long contractor;

    /**
    * 签约时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDateTime signingTime;

    /**
     * 附件
     */
    private String attachment;

    /**
     * 合同金额
     */
    private BigDecimal amount;

    /**
     * 是否最终版
     */
    private Boolean isFinal;

    /**
    * 交货时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDateTime deliveryTime;

    /**
     * 合同存放地点
     */
    private String address;

    /**
     * 合同保管员ID
     */
    private Long keeper;

    /**
     * 信息审批人ID
     */
    private Long approver;

    /**
     * 状态
     */
    private Status status;

    /**
    * 状态描述
    */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 审核意见
     */
    private String auditOpinion;

}
